﻿using Mathmall.Administration.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

namespace Mathmall.Administration.Data
{
    public class AdministrationContext : IdentityDbContext<User, IdentityRole<int>, int>
    {
        public AdministrationContext(DbContextOptions<AdministrationContext> options) : base(options)
        {
        }

        public DbSet<Attr> Attrs { get; set; }
        public DbSet<AttrAttrgroupRelation> AttrAttrgroupRelations { get; set; }
        public DbSet<AttrGroup> AttrGroups { get; set; }
        public DbSet<Brand> Brands { get; set; }
        public DbSet<Category> Categories { get; set; }
        public DbSet<CategoryBrandRelation> CategoryBrandRelations { get; set; }
        public DbSet<CommentReplay> CommentReplays { get; set; }
        public DbSet<ProductAttrValue> ProductAttrValues { get; set; }
        public DbSet<SkuImage> SkuImages { get; set; }
        public DbSet<SkuInfo> SkuInfos { get; set; }
        public DbSet<SkuSaleAttrValue> SkuSaleAttrValues { get; set; }
        public DbSet<SpuComment> SpuComments { get; set; }
        public DbSet<SpuImage> SpuImages { get; set; }
        public DbSet<SpuInfo> SpuInfos { get; set; }
        public DbSet<SpuInfoDescription> SpuInfoDescriptions { get; set; }
        public DbSet<Menu> Menus { get; set; }
        public DbSet<RoleMenu> RoleMenu { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            new AttrEntityTypeConfiguration().Configure(modelBuilder.Entity<Attr>());
            new AttrAttrgroupRelationEntityTypeConfiguration().Configure(modelBuilder.Entity<AttrAttrgroupRelation>());
            new AttrGroupEntityTypeConfiguration().Configure(modelBuilder.Entity<AttrGroup>());
            new BrandEntityTypeConfiguration().Configure(modelBuilder.Entity<Brand>());
            new CategoryEntityTypeConfiguration().Configure(modelBuilder.Entity<Category>());
            new CategoryBrandRelationEntityTypeConfiguration().Configure(modelBuilder.Entity<CategoryBrandRelation>());
            new CommentReplayEntityTypeConfiguration().Configure(modelBuilder.Entity<CommentReplay>());
            new ProductAttrValueEntityTypeConfiguration().Configure(modelBuilder.Entity<ProductAttrValue>());
            new SkuImagesEntityTypeConfiguration().Configure(modelBuilder.Entity<SkuImage>());
            new SkuInfoEntityTypeConfiguration().Configure(modelBuilder.Entity<SkuInfo>());
            new SkuSaleAttrValueEntityTypeConfiguration().Configure(modelBuilder.Entity<SkuSaleAttrValue>());
            new SpuCommentEntityTypeConfiguration().Configure(modelBuilder.Entity<SpuComment>());
            new SpuImageEntityTypeConfiguration().Configure(modelBuilder.Entity<SpuImage>());
            new SpuInfoEntityTypeConfiguration().Configure(modelBuilder.Entity<SpuInfo>());
            new SpuInfoDescEntityTypeConfiguration().Configure(modelBuilder.Entity<SpuInfoDescription>());
            new UserEntityTypeConfiguration().Configure(modelBuilder.Entity<User>());
            new MenuEntityTypeConfiguration().Configure(modelBuilder.Entity<Menu>());
            new RoleMenuEntityTypeConfiguration().Configure(modelBuilder.Entity<RoleMenu>());
        }
    }
}